class RpcController(object):
  def __init__(self):
    self.reset()

  def reset(self):
    self._error_code = None
    self._error_text = None
    self._cancel = False
    self._request = None
    self._callback = None
    self._response = None
    self._local_context = None

  def error_text(self):
    return self._error_text

  def error_code(self):
    return self._error_code

  def failed(self):
    return self._error_code or self._error_text

  def set_failed(self, reason, code=0):
    self._error_text = reason
    self._error_code = code

  def start_cancel(self):
    self._cancel = true

  def is_canceled(self):
    return self._cancel

  def local_context(self):
    return self._local_context

  def set_local_context(self, local_context):
    self._local_context = local_context

  def request(self):
    return self._request

  def set_request(self, request):
    self._request = request

  def callback(self):
    return self._callback

  def set_callback(self, callback):
    self._callback = callback

  def response(self):
    return self._response

  def set_response(self, builder):
    self._response = builder

